<?php
/**
 * Created by PhpStorm.
 * User: zouyanan
 * Date: 2019/5/11
 * Time: 下午10:35
 */

namespace app\api\controller;


use app\common\controller\Api;
use fast\Pinyin;
class Friends extends Api
{
    protected $noNeedLogin = ['detail'];
    protected $noNeedRight = '*';
    protected $websiteUrl = 'http://api.yjzufang.com';

    //获取人脉列表
    public function connections()
    {
        header('Access-Control-Allow-Origin: *');
        header('Access-Control-Allow-Credentials: true');
        header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
        header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
        ob_clean();
        $userInfo = $this->auth->getUserinfo();
        $first = array_unique(db("yjy_house_landlord")->where("agent_id",$userInfo['id'])->order("first asc")->column("first"));
        $arr = [];
        foreach($first as $key=>$val){
            $list = db("yjy_house_landlord")->where("first",$val)->field("id,pinyin as spell,name")->select();
           $arr[$val] = $list;
        }
        $this->success("返回成功",$arr);


    }


    //获取单个人脉信息
    public function detail(){
        header('Access-Control-Allow-Origin: *');
        header('Access-Control-Allow-Credentials: true');
        header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
        header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
        ob_clean();
        $id = $this->request->request("id");
        $info = db("yjy_house_landlord")
            ->where("id",$id)
            ->field("mobile,agent_id")
            ->find();


        $this->success("返回成功",$info);
    }








}